// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import Vuex from 'vuex'
import VueLazyload from 'vue-lazyload'
import infiniteScroll from  'vue-infinite-scroll'
//价格过滤器全局使用
import {currency} from './util/currency'

import './assets/css/base.css'
import './assets/css/checkout.css'
import './assets/css/product.css'

//滚动加载插件
Vue.use(infiniteScroll);
Vue.use(Vuex);
//图标插件
Vue.use(VueLazyload, {
  loading: 'static/loading-svg/loading-bars.svg',
  try: 3 // default 1
})
//价格过滤器全局使用
Vue.filter("currency",currency);
Vue.config.productionTip = false;
//
const store = new Vuex.Store({
  state: {
    nickName:'',
    cartCount:0
  },
  mutations: {
    //更新用户信息
    updateUserInfo(state, nickName) {
      state.nickName = nickName;
    },
    initCartCount(state,cartCount){
      state.cartCount = cartCount;
    },
    addCartCount(state){//加1
      state.cartCount = state.cartCount + 1
    },
    minusCartCount(state,num){//减去1或当前商品的数量
       state.cartCount = state.cartCount - num
    }
  }
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router,
  template: '<App/>',
  //render: h => h(App),
  components: { App }
});//.$mount('#app')
